// if you use a different editor, the function generally
// is called on formst that are using the create_editor_instance function
// and with quickform, youll need to save the data before validating it
// so whatever editor you use, call its save function first
function editorSave(){
   tinyMCE.triggerSave();
}
function delete_confirm(id){
    var kill = document.getElementById(id);
    if(confirm('Are you SURE you want to delete this item? This can not be undone.')){
        new Effect.Squish(kill);
        return true;
    }else{
        return false;
    } 
    return false;
}
sfHover = function() {
	var sfEls = document.getElementById("admin_nav_list").getElementsByTagName("LI");
	if(sfEls){
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {
				this.className+=" sfhover";
			}
			sfEls[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
			}
		}
	}
}
function toggle_success()
{        
    Effect.toggle('success_messages', 'appear');        
    setTimeout("new Effect.Fade('success_messages')",3000)       
}
//if (window.attachEvent) window.attachEvent("onload", sfHover);

// usage: <a href="#" onclick="Effect.toggle('by_category','appear');Element.activate('rc',!$('rc')['active'])" id='rc' activetext='Close Report By Category' activeclass='active'>Report By Category</a>
if (!window.Element)  var Element = new Object();
Element.activate = function(element, activate) {
    element = $(element)

    // get the inactive text, which defaults to the element's innerHTML
    var inactive_text = element['inactivetext']
    if(!inactive_text) {
      element['inactivetext'] = element.innerHTML
      inactive_text = element.innerHTML
    }

    // get the active text and active class, which default to the current
    // innerHTML and className, respectively
    var active_text = element.getAttribute('activetext') ||
      element.innerHTML
    var active_class = element.getAttribute('activeclass') ||
      element.className

    if(!activate) {
      element.innerHTML = inactive_text
      if(active_class) Element.removeClassName(element, active_class)
      element['active'] = false
    } else {
      element.innerHTML = active_text
      if(active_class) Element.addClassName(element, active_class)
      element['active'] = true
    }
}


/*
var GlobalAjaxErrors = {
    onComplete: function(){
        if (Ajax.responseText)
    }
};
*/
// ajax default busy thingie
Ajax.Responders.register({
  onCreate: function() {
    if($('busy') && Ajax.activeRequestCount>0)
      Effect.Appear('busy',{duration:0.5,queue:'end'});
  },
  onComplete: function() {
    if($('busy') && Ajax.activeRequestCount==0)
      Effect.Fade('busy',{duration:0.5,queue:'end'});
  }
});

